#include <matrix.hpp>

#include <iostream>
#include <algorithm>

#include <iomanip>

#include <random.hpp>


using namespace std;
using namespace sm;

int main()
{
	cout << setprecision(1);

	feng::variate_generator<long double> Ran;

	static_matrix<long double, 10, 10> m1;
	fill(m1.begin(), m1.end(), Ran());
	fill(m1.diag_begin(), m1.diag_end(), -10.0 );
	fill(m1.upper_diag_begin(5), m1.upper_diag_end(5), -1.0 );
	fill(m1.col_begin(3), m1.col_end(3), 9.8);
	fill(m1.row_begin(7), m1.row_end(7), -2.9);
	cout << "\nm1 = \n" << m1 << endl;

	static_matrix<long double, 11, 9> m2;
	fill(m2.begin(), m2.end(), 10.0);
	cout << "\nm2 = \n" << m2 << endl;
	
	static_matrix<long double, 10, 10> m3;
	fill(m3.begin(), m3.end(), Ran());
	fill(m3.diag_begin(), m3.diag_end(), -9.0);
	fill(m3.upper_diag_begin(5), m3.upper_diag_end(5), 17.0 );
	fill(m3.lower_diag_begin(1), m3.lower_diag_end(1), 117.0 );
	fill(m3.col_begin(2), m3.col_end(2), 7.8);
	fill(m3.row_begin(9), m3.row_end(9), -1.3);
	cout << "\nm3 = \n" << m3 << endl;
	cout << "\n1/m3 = \n" << 1.0/m3 << endl;
	
	static_matrix<long double, 10, 10> m4;
	m4 = m3*m1;
	cout << "\nm4 = \n" << m4 << endl;

	static_matrix<long double, 10, 10> m5;
	m5 = m4/m1;
	cout << "\nm5 = \n" << m5 << endl;
	cout << "\nm3 = \n" << m3 << endl;

	cout << "\nm5*m5^{-1} = \n" << m5 * m5.invert() << endl;


	static_matrix<long double, 200, 200> m6;
	fill(m6.begin(), m6.end(), Ran());
	static_matrix<long double, 200, 200> m7 = m6.invert();
	cout << "\nm6*m6^{-1} =\n" << m6 * m7 << "\n";
	


	return 0;
}
